package io.renren.modules.welder.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.welder.entity.WelderEntity;
import io.renren.modules.welder.service.WelderService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

@RestController
@RequestMapping("welder/welder")
public class WelderController {
    @Autowired
    private WelderService welderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("welder:welder:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = welderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{wNo}")
    @RequiresPermissions("welder:welder:info")
    public R info(@PathVariable("wNo") Integer wNo){
		WelderEntity welder = welderService.getById(wNo);

        return R.ok().put("welder", welder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("welder:welder:save")
    public R save(@RequestBody WelderEntity welder){
		welderService.save(welder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("welder:welder:update")
    public R update(@RequestBody WelderEntity welder){
		welderService.updateById(welder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("welder:welder:delete")
    public R delete(@RequestBody Integer[] wNos){
		welderService.removeByIds(Arrays.asList(wNos));

        return R.ok();
    }

}
